<div class="headbar">
	<div class="position"><span>工具</span><span>></span><span>关键词管理</span><span>></span><span>关键词列表</span></div>
	<div class="operating">
		<a href="javascript:void(0)" onclick="event_link('{url:/tools/keyword_edit}');"><button class="operating_btn" type="button"><span class="addition">添加关键词</span></button></a>
		<a href="javascript:void(0)" onclick="selectAll('id[]');"><button class="operating_btn" type="button"><span class="sel_all">全选</span></button></a>
		<a href="javascript:void(0)" onclick="delModel();"><button class="operating_btn" type="button"><span class="delete">批量删除</span></button></a>
		<a href="javascript:void(0)" onclick="window.document.forms[0].action='{url:/tools/keyword_account}';delModel({msg:'是否批量同步？'});"><button class="operating_btn" type="button"><span class="refresh">批量同步</span></button></a>
	</div>
</div>
<div class="content">
	<form action="{url:/tools/keyword_del}" method="post">
		<table class="list_table">
			<colgroup>
				<col width="40px" />
				<col width="250px" />
				<col width="120px" />
				<col width="100px" />
				<col />
			</colgroup>

			<thead>
				<tr>
					<th>选择</th>
					<th>关键词</th>
					<th>关联商品数量</th>
					<th>是否热门</th>
					<th>排序</th>
				</tr>
			</thead>

			<tbody>
				{set:$page= (isset($_GET['page'])&&(intval($_GET['page'])>0))?intval($_GET['page']):1;}
				{query: name=keyword page=$page order=`order` asc}
				<tr>
					<td><input type="checkbox" name="id[]" value="{$item['word']}" /></td>
					<td>{$item['word']}</td>
					<td>{$item['goods_nums']}</td>
					<td>
						{if:$item['hot']==1}
						<a class='red2' href='javascript:void(0);' onclick='set_hot("{$item['word']}",this);'>是</a>
						{else:}
						<a class='blue' href='javascript:void(0);' onclick='set_hot("{$item['word']}",this);'>否</a>
						{/if}
					</td>
					<td>
						<input type='text' maxlength='6' onblur='set_order("{$item['word']}",this,"{$item['order']}");' class='tiny' value='{$item['order']}' />
					</td>
				</tr>
				{/query}
			</tbody>
		</table>
	</form>
</div>
{$query->getPageBar()}

<script type='text/javascript'>
//设置热门关键词
function set_hot(word,obj)
{
	var rd = Math.random();
	$.getJSON('{url:/tools/keyword_hot/hot/1}',{id:word,rd:rd},function(content){
		if(content.isError ==  false)
		{
			if(content.hot == 1)
			{
				obj.innerHTML = '是';
				$(obj).removeClass('blue');
				$(obj).addClass('red2');
			}
			else
			{
				obj.innerHTML = '否';
				$(obj).removeClass('red2');
				$(obj).addClass('blue');
			}
		}
		else
		{
			alert(content.message);
		}
	});
}

//设置排序
function set_order(word,obj,default_val)
{
	var order = $(obj).val();
	if(isNaN(order))
	{
		alert('排序必须是一个数字');
		$(obj).val(default_val);
	}
	else
	{
		$.getJSON('{url:/tools/keyword_order}',{id:word,order:order},function(content){
			if(content.isError == true)
			{
				alert(content.message);
			}
		});
	}
}
</script>
